﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MoneyManager
{
    static class Log
    {
        private static TextWriter LogWriter;
        static Log()
        {
            String time = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-");
            LogWriter = TextWriter.Synchronized(new StreamWriter(".\\log " + time + ".log"));
        }

        public static void WriteError(String error)
        {
            string logmessage = DateTime.Now.ToString() + ": ERROR: " + error;
            LogWriter.WriteLine(logmessage);
            LogWriter.Flush();
        //    LogWindow.AddMessage(logmessage);
        }

        public static void WriteInfo(String message)
        {
            string logmessage = DateTime.Now.ToString() + ": " + message;
            LogWriter.WriteLine(logmessage);
            LogWriter.Flush();
        //    LogWindow.AddMessage(logmessage);
        }

        public static void WriteStrings(IEnumerable<string> strs)
        {
            LogWriter.WriteLine(DateTime.Now.ToString());
            foreach (var str in strs)
                LogWriter.WriteLine(str);
            LogWriter.Flush();
        }
    }
}
